# -*- encoding: utf-8 -*-
"""

PyCharm len函数的使用方法
2024年10月20日21时50分
by wenyang

"""
class Student:
    def __init__(self):
        self.stu = []
        self.index = 0
    def add_student(self):
        student = {}
        student["name"] = input("请输入学生的姓名\n")
        self.stu.append(student)
    def __iter__(self):
        return self
    def __next__(self):
        if self.index < len(self.stu):
            result = self.stu[self.index]
            self.index += 1
            return result
        else:
            raise StopIteration
    # len()本质上即时调用这个方法
    def __len__(self):
        return 10

def main():
    str = "hello world"
    print(len(str))
    list_items = ["hello world", "javascript", "python"]
    print(len(list_items))
    stu = Student()
    stu.add_student()
    print(len(stu))


if __name__ == "__main__":
    main()
